﻿using System;
using BootstrapBlazor.Components;
using Microsoft.AspNetCore.Components;
using System.Diagnostics.CodeAnalysis;
using iTeamyou.LTS.UI.Models;

namespace iTeamyou.LTS.UI.Shared.Components
{
    public partial class LicenseCountFilter
    {
        private int Value = 10;

        /// <summary>
        /// OnInitialized 方法
        /// </summary>
        protected override void OnInitialized()
        {
            base.OnInitialized();

            if (TableFilter != null) TableFilter.ShowMoreButton = false;

            Items = new SelectedItem[]
            {
            new SelectedItem { Value = "1", Text = "有证照" },
            new SelectedItem { Value = "0", Text = "无证照" }
            };
        }

        /// <summary>
        /// 重置过滤条件方法
        /// </summary>
        public override void Reset()
        {
            Value = 10;

            StateHasChanged();
        }

        /// <summary>
        /// 生成过滤条件方法
        /// </summary>
        /// <returns></returns>
        public override FilterKeyValueAction GetFilterConditions()
        {
            var filter = new FilterKeyValueAction() { Filters = new() };
            filter.Filters.Add(new FilterKeyValueAction()
            {
                FieldKey = FieldKey,
                FieldValue = Value,
                FilterAction = FilterAction.NotEqual
            });
            return filter;
        }
    }
}

